From 775e6c759cfdc54028795c23f83b41215d903e99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jerome=20K=C3=BCttner?= Date: Mon, 20 Oct 2025 18:53:38 +0200 Subject: [PATCH] dhcpv6: return early upon success MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Once a "DHCPV6_Success" status is seen, don’t abort on subsequent non-Success to prevent "No Address Available" errors. Signed-off-by: Jerome Küttner Link: https://github.com/openwrt/odhcp6c/pull/90 Signed-off-by: Álvaro Fernández Rojas --- src/dhcpv6.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 6aed871..8317d83 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -1368,6 +1368,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc, uint16_t code = DHCPV6_Success; uint16_t stype, slen; uint8_t *sdata; + bool dhcpv6_successful_once = false; // Get and handle status code dhcpv6_for_each_option(&ia_hdr[1], odata + olen, stype, slen, sdata) { @@ -1377,8 +1378,10 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc, code = ((int)sdata[0]) << 8 | ((int)sdata[1]); - if (code == DHCPV6_Success) + if (code == DHCPV6_Success) { + dhcpv6_successful_once = true; continue; + } dhcpv6_handle_ia_status_code(orig, ia_hdr, code, mdata, mlen, handled_status_codes, &ret); @@ -1387,7 +1390,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc, } } - if (code != DHCPV6_Success) + if (!dhcpv6_successful_once && code != DHCPV6_Success) continue; updated_IAs += dhcpv6_parse_ia(ia_hdr, odata + olen, &ret); -- 2.30.2